<%@ Page Language="C#" EnableViewState="false" ValidateRequest="false" AutoEventWireup="true" 
	 MasterPageFile="~/App_ThemeMasters/NoStyle/AdminOneColumnLayout.Master" Inherits="Syrinx.Gui.AspNet.Ajax.NitobiBasePage" %>
<%@ Register Assembly="Swaf.Gui.AspNet2" Namespace="Swaf.Gui.AspNet2" TagPrefix="swf" %>
<%@ Register Assembly="ScsAspNet" Namespace="Syrinx.Gui.AspNet.Ajax" TagPrefix="saj" %><%@ Register Assembly="NitobiControls" Namespace="Nitobi" TagPrefix="ntb" %>
<%@ Register Assembly="ScsAspNet" Namespace="Articles.Gui.AspNet" TagPrefix="art" %>
<%@ Register Assembly="ScsAspNet" Namespace="Syrinx.Gui.AspNet" TagPrefix="syx" %>

<!--#include file="~/SiteControls/RegisterStandardControls.txt"-->
<!--#include file="../SiteControls/StandardAdminHeaderPageContent.inc"-->
<!--#include file="../SiteControls/StandardFooterPageContent.inc"-->

<script runat="server">
	public string TitleFormat = "$company.name$ - Article Management";
</script>

<asp:Content ID="c1" ContentPlaceHolderID="title" runat="server">
	<%SecurityPrivilege = "AppFunctions.ManageArticles"; %>
    <swf:BizProc ID="contacts" runat="server" FactoryName="contactBizProc">
		<State includeContactAddresses="true" />
		<ParentBizProc id="loginBP" />
    </swf:BizProc>
    <swf:BizProc ID="conTypeBP" runat="server" FactoryName="contactTypes">
		<ParentBizProc id="loginBP" />
    </swf:BizProc>
    <swf:BizProc ID="addrTypeBP" runat="server" FactoryName="addressTypes">
		<ParentBizProc id="loginBP" />
    </swf:BizProc>
    <swf:BizProc ID="addrBP" runat="server" FactoryName="contactAddresses">
		<ParentBizProc id="contacts" fieldName="addresses" dataId="parent" fullDependency="True" cacheValue="false" />
    </swf:BizProc>
    <swf:BizProc ID="gmapBP" runat="server" FactoryName="gmap">
		<ParentBizProc id="contacts" dataId="dataSource" fieldName="addresses" meta="includeContacts" />
		
		<ParentBizProc id="conTypeBP" dataId="mapPin" />
		<ParentBizProc id="addrTypeBP" dataId="mapPin" />		
    </swf:BizProc>
    
	<div style="float:left"><h1 ID="_ImgCacheLibLbl" runat="server">Contact Management</h1></div>
	<div style="float:right"><div class="HelpBtnArea">
		<asp:HyperLink runat="server" ID="_pageHelp" NavigateUrl="../std/Help.aspx?helpid=ContactManagementHelp" Target="help">Help</asp:HyperLink>
	</div>
	</div>

</asp:Content>

<asp:Content ContentPlaceHolderID="headSection" runat="server">
<script type="text/javascript">
function toggleTabs(cId,c1, dId){
	for(i=1; ;i++){
		var a = document.getElementById(cId + i);
		var b = document.getElementById(dId + i);
		if(a==null || a=='')
			break;
			
		if(i==c1){
			a.className = 'currenttab';
			b.style.display = 'block';
		}
		else{
			a.className='';
			b.style.display = 'none';
		}
	}
}
</script>
</asp:Content>

<asp:Content ID="c3" ContentPlaceHolderID="mainContent" runat="server">
	<table class="adminPageWidth" ><tr><td >
    <div class="SimpleVerticalBg"> 
	    <saj:Grid ID="articleList1Display" runat="server" Width="350px" Height="600px"
		    ParentBizProcIds="contacts" Mode="LiveScrolling" Resizable="Both" >
			<Toolbars>
				<ntb:GridToolbar Title="ExtraInfo">
					<ntb:TotalRowsInfoItem CssStyle="margin-top:4px;float:left;">
						Total Contact <b>{0}</b>
					</ntb:TotalRowsInfoItem>
				</ntb:GridToolbar>
			</Toolbars>
		    <Columns>
			    <ntb:KeyColumn DataField="id" />
			    <ntb:BoundColumn DataField="lastName" HeaderText="Last Name" width="90" />
			    <ntb:BoundColumn DataField="firstName" HeaderText="First Name" Width="90" />
			    <ntb:BoundColumn DataField="type.name" HeaderText="Type" Width="90" />
			    <ntb:BoundColumn DataField="email" HeaderText="EMail" Width="120" />
		    </Columns>
	    </saj:Grid>
    </div>
</td><td class="adminRightContentWidth">
		<div class="tabs">
			<ul>
				<li id="t1" class="currenttab"><div class="firstTab"><swf:DivLayers runat="server" ID="tl1" SkinID="Tab"><asp:HyperLink onclick="toggleTabs('t','1','ta');" runat="server" ID="_cmpMngrTab1" Text="Contact Details" NavigateUrl="javascript:;" /></swf:DivLayers></div></li>
				<li id="t3"><swf:DivLayers runat="server" ID="tl3" SkinID="Tab"><asp:HyperLink runat="server" onclick="toggleTabs('t','3','ta');window.setTimeout('refreshGMaps();',50);" ID="_pubInfLbl" Text="Contacts Map" NavigateUrl="javascript:;" /></swf:DivLayers></li>
				<li id="t2"><div class="lastTab"><swf:DivLayers runat="server" ID="tl2" SkinID="Tab"><asp:HyperLink runat="server" onclick="toggleTabs('t','2','ta');" ID="_cmpMngrTab3" Text="Contact/Address Types" NavigateUrl="javascript:;" /></swf:DivLayers></div></li>
			</ul>
		</div>
	<swf:DivLayers ID="mdl1" runat="server" SkinID="MainTabArea">
		<div id="ta1">
			<div class="ActionButtonArea">
				<saj:ActionButton runat="server" ID="updateBtn1" Actions="contacts.UpdateBizObj" Text="Update" />
				<saj:ActionButton runat="server" ID="addBtn" Actions="contacts.AddBizObj" Text="Add" />
				<saj:ActionButton runat="server" ID="cancelBtn" Actions="contacts.CancelEdits" Text="Cancel" />
				<saj:ActionButton runat="server" ID="deleteBtn" Actions="contacts.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;"/>
				<saj:ActionButton runat="server" ID="editMode" Actions="contacts.SwitchEdit" Text="Edit" SessionBoolSwitch="GlobalEdit" />
			</div>
			<saj:NitobiBizObjDisplay runat="server" ID="conD1" ParentBizProcIds="contacts"
				EditableTemplate="Contacts.Gui.AspNet.ContactRWDisplay-NamePhoneEmail,Contacts.Gui.AspNet.ContactRWDisplay-TypeUserInfo">
			</saj:NitobiBizObjDisplay>
			<div class="FieldLine">
				<div class="SideFieldSet">
					<asp:Label ID="_addrLbl" runat="server" Text="Addresses" CssClass="Label"  />
					<div class="Field">
						<saj:Grid ID="addrList" runat="server" Width="450px" Height="250px" 
							UpdateOnRowChange="false" AjaxEventOnRowSelect="false"
							AllowAddRow="true" AllowDeleteRow="true" AllowSorting="false"
							ParentBizProcIds="addrBP" Mode="LiveScrolling" Resizable="Both" >
							<Toolbars>
								<ntb:GridToolbar Title="ExtraInfo">
									<ntb:AddButtonItem Tooltip="Add New Address" />
									<ntb:DeleteButtonItem Tooltip="Delete Selected Address" />
									<ntb:RefreshButtonItem Tooltip="Refesh Address List and Lose Changes Not Saved" />
									<ntb:ButtonItem Id="map" ImageUrl="/images/mapIcon.gif" Tooltip="Get Longitude/Latitude for Selected Address from Google Map" 
										Click="var addr = window.showModalDialog('../popups/MapAddress.aspx',getGridRowInfo('ctl00_mainContent_addrList'),'dialogWidth:400px; dialogHeight:400px; center:yes; resizable: yes; help: no ');updateGridRowInfo('ctl00_mainContent_addrList',addr);" />
								</ntb:GridToolbar>
							</Toolbars>
							<Columns>
								<ntb:KeyColumn DataField="id" />
								<ntb:ComboColumn DataField="type.id" HeaderText="Type" Width="100" ReadOnly="false"
										 ValueField="id" DataSourceId="getAddressTypes" GetDataUrl="/NitobiLiveStreamHandler.aspx?pi=syrinxph/">
									<ntb:BoundColumn DataField="id" visible="false" />
									<ntb:BoundColumn DataField="title" width="150" />
								</ntb:ComboColumn>
								<ntb:BoundColumn DataField="street1" HeaderText="Street" width="160" ReadOnly="false" />
								<ntb:BoundColumn DataField="city" HeaderText="City" Width="90" ReadOnly="false" />
								<ntb:BoundColumn DataField="stateProvince" HeaderText="State" Width="70" ReadOnly="false" />
								<ntb:BoundColumn DataField="zipCode" HeaderText="Zip" Width="60" ReadOnly="false" />
								<ntb:ComboColumn DataField="country.regionCode" HeaderText="Country" Width="100" ReadOnly="false"
										 ValueField="regionCode" DataSourceId="getCountries" GetDataUrl="/NitobiLiveStreamHandler.aspx?pi=syrinxph/">
									<ntb:BoundColumn DataField="regionCode" visible="false" />
									<ntb:BoundColumn DataField="name" width="150" />
								</ntb:ComboColumn>
								<ntb:BoundColumn DataField="longitude" HeaderText="Lng" Width="30" />
								<ntb:BoundColumn DataField="latitude" HeaderText="Lat" Width="30" />
							</Columns>
						</saj:Grid>
					</div>
				</div>
			</div>
        </div>
        
        <div id="ta2" style="display:none;">
        
			<span style="display:none"><saj:ActionButton runat="server" ID="updateConType" Actions="conTypeBP.UpdateBizObj" Text="Update" /></span>
			<div class="FieldLine">
				<div class="SideFieldSet">
					<asp:Label ID="_typesLbl" runat="server" Text="Contact Types" CssClass="Label"  />
					<div class="Field">
						<saj:Grid ID="typesGr" runat="server" Width="450px" Height="250px" 
							AllowAddRow="true" AllowDeleteRow="true" AllowSorting="false" RowHeight="40"
							UpdateOnRowChange="false" AjaxEventOnRowSelect="false"
							ParentBizProcIds="conTypeBP" Mode="LiveScrolling" Resizable="Both" >
							<Toolbars>
								<ntb:GridToolbar Title="ExtraInfo">
									<ntb:AddButtonItem Tooltip="Add New Contact Type" />
									<ntb:DeleteButtonItem Tooltip="Delete Selected Contact Type" />
									<ntb:RefreshButtonItem Tooltip="Refesh Contact Type List and Lose Changes Not Saved" />
									<ntb:SeparatorItem />
									<ntb:ButtonItem Id="img" ImageUrl="/images/mapIcon.gif" Tooltip="Set Contact Map Pin Image" 
										Click="var bizObj = window.showModalDialog('/popups/PickImagePopup.aspx',{imageFieldName:'mapImageUrl', bizObj: getGridRowInfo('ctl00_mainContent_typesGr')},'dialogWidth:400px; dialogHeight:400px; center:yes; resizable: yes; help: no ');updateGridRowInfo('ctl00_mainContent_typesGr',bizObj);" />
									<ntb:SeparatorItem />
									<ntb:SaveButtonItem Click="conTypeBPBizProc.triggerEvent('ctl00_mainContent_updateConType','UpdateBizObj');" />
									<ntb:SeparatorItem />
									<ntb:TotalRowsInfoItem CssStyle="margin-top:4px;float:left;">
										<div style='padding-left:10px;'>Total Contact Types <b>{0}</b></div>
									</ntb:TotalRowsInfoItem>
								</ntb:GridToolbar>
							</Toolbars>
							<Columns>
								<ntb:KeyColumn DataField="id" />
								<ntb:BoundColumn DataField="name" HeaderText="Name" width="120" ReadOnly="false" />
								<ntb:ImageColumn DataField="mapImageUrl" HeaderText="Map Pin" width="55" />
							</Columns>
						</saj:Grid>
					</div>
				</div>
			</div>
			
			<span style="display:none"><saj:ActionButton runat="server" ID="updateAddrType" Actions="addrTypeBP.UpdateBizObj" Text="Update" /></span>
			<div class="FieldLine">
				<div class="SideFieldSet">
					<asp:Label ID="_lbladdrty" runat="server" Text="Address Types" CssClass="Label"  />
					<div class="Field">
						<saj:Grid ID="addrGrid" runat="server" Width="450px" Height="250px" 
							AllowAddRow="true" AllowDeleteRow="true" AllowSorting="false" RowHeight="40"
							UpdateOnRowChange="false" AjaxEventOnRowSelect="false"
							ParentBizProcIds="addrTypeBP" Mode="LiveScrolling" Resizable="Both" >
							<Toolbars>
								<ntb:GridToolbar Title="LeftSide">
									<ntb:AddButtonItem Tooltip="Add New Address Type" />
									<ntb:DeleteButtonItem Tooltip="Delete Selected Address Type" />
									<ntb:RefreshButtonItem Tooltip="Refesh Address Type List and Lose Changes Not Saved" />
									<ntb:SeparatorItem />
									<ntb:ButtonItem Id="img2" ImageUrl="/images/mapIcon.gif" Tooltip="Set Contact Map Pin Image" 
										Click="var bizObj = window.showModalDialog('/popups/PickImagePopup.aspx',{imageFieldName:'mapImageUrl', bizObj: getGridRowInfo('ctl00_mainContent_addrGrid')},'dialogWidth:400px; dialogHeight:400px; center:yes; resizable: yes; help: no ');updateGridRowInfo('ctl00_mainContent_addrGrid',bizObj);" />
									<ntb:SeparatorItem />
									<ntb:SaveButtonItem Click="addrTypeBPBizProc.triggerEvent('ctl00_mainContent_updateAddrType','UpdateBizObj');" />
									<ntb:SeparatorItem />
									<ntb:TotalRowsInfoItem CssStyle="margin-top:4px;float:left;">
										<div style='padding-left:10px;'>Total Address Types <b>{0}</b></div>
									</ntb:TotalRowsInfoItem>
								</ntb:GridToolbar>
							</Toolbars>
							<Columns>
								<ntb:KeyColumn DataField="id" />
								<ntb:BoundColumn DataField="title" HeaderText="Name" width="120" ReadOnly="false" />
								<ntb:ImageColumn DataField="mapImageUrl" HeaderText="Map Pin" width="55" />
							</Columns>
						</saj:Grid>
					</div>
				</div>
			</div>

        </div>
        
		<div id="ta3" style="display:none">
			<saj:NitobiGoogleMapBizObjListDisplay runat="server" id="testM" ParentBizProcIds="gmapBP" ShowMarkerNav="true"
				InitialZoom="13" PanZoom="largePanZoom" ShowMapTypes="true" Width="450px" Height="450px" />
		</div>
    </swf:DivLayers>
</td></tr></table>    
</asp:Content>
